<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>如何来获取随机颜色</title>
    
</head>
<body>
    <script type="text/javascript">
        // 获取随机颜色 rgb(0~255,0~255,0~255)
        function random(max,min){
            return Math.floor(Math.random()*(max-min)+min);
        }

        function randomColor(){
            var r = random(0, 256);
            var g = random(0, 256);
            var b = random(0, 256);
            // 模板字符串''
            var result = `rgb(${r},${g},${b})`
            return result;
        }
        console.log(randomColor())
        document.body.style.backgroundColor = randomColor();
    </script>
</body>
</html>